package com.waterfallscroll.view.adapter;

import android.content.Context;
import android.view.View;


import com.waterfallscroll.view.interf.WaterfallAdapterInterface;
import com.waterfallscroll.view.interf.WaterfallItemViewInitInfterface;

import java.util.List;

/**
 * <h3>Description</h3> 适配器基类
 * TODO
 * <h3>Author</h3> luzhenbang
 * <h3>Date</h3> 2016/1/14 11:51
 * <h3>Copyright</h3> Copyright (c)2016 Shenzhen Tentinet Technology Co., Ltd. Inc. All rights reserved.
 */
public abstract class WaterfallBaseAdapter<T> implements WaterfallAdapterInterface , WaterfallItemViewInitInfterface {
    /**数据源*/
    private List<T> list;
    private Context context;
    /**
     * 有参构造方法
     * <h3>Version</h3> 1.0
     * <h3>CreateTime</h3> 2016/1/14,11:55
     * <h3>UpdateTime</h3> 2016/1/14,11:55
     * <h3>CreateAuthor</h3> luzhenbang
     * <h3>UpdateAuthor</h3>
     * <h3>UpdateInfo</h3> (此处输入修改内容,若无修改可不写.)
     *
     * @param list 数据源集合
     */
    public WaterfallBaseAdapter(List<T> list , Context context ) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getItemsCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public T getItem(int position) {
        return list == null ? null : list.get(position);
    }


    @Override
    public void initChildViewOfItemView(View itemView , Object object) {
        initChildrenViewOfItemView(itemView,object);
    }


    /**
     * 初始化item的子控件
     * <h3>Version</h3> 1.0
     * <h3>CreateTime</h3> 2016/1/15,11:37
     * <h3>UpdateTime</h3> 2016/1/15,11:37
     * <h3>CreateAuthor</h3> luzhenbang
     * <h3>UpdateAuthor</h3>
     * <h3>UpdateInfo</h3> (此处输入修改内容,若无修改可不写.)
     * 
     * @param itemView item 的布局
     * @param o  item的数据
     */
    public abstract void initChildrenViewOfItemView (View itemView , Object o);
    /**
     * 更新数据
     * <h3>Version</h3> 1.0
     * <h3>CreateTime</h3> 2016/1/14,12:05
     * <h3>UpdateTime</h3> 2016/1/14,12:05
     * <h3>CreateAuthor</h3> luzhenbang
     * <h3>UpdateAuthor</h3>
     * <h3>UpdateInfo</h3> (此处输入修改内容,若无修改可不写.)
     *
     */
    public void notifyToChangeData(List<T> list){
          if (list != null){
              this.list = list;
          }
    }


}
